<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>RobotClient: ClientMain.cpp源文件</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">RobotClient
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- 制作者 Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="namespaces.html"><span>命名空间</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>文件成员</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_client_main_8cpp.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">ClientMain.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_client_main_8cpp.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// *** ADDED BY HEADER FIXUP ***</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;wx/gdicmn.h&gt;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;wx/menuitem.h&gt;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;wx/utils.h&gt;</span>
<a name="l00005"></a>00005 <span class="comment">// *** END ***</span>
<a name="l00006"></a>00006 <span class="comment">/***************************************************************</span>
<a name="l00007"></a>00007 <span class="comment"> * Name:      ClientMain.cpp</span>
<a name="l00008"></a>00008 <span class="comment"> * Purpose:   Code for Application Frame</span>
<a name="l00009"></a>00009 <span class="comment"> * Author:    sleepiforest (248023406@qq.com)</span>
<a name="l00010"></a>00010 <span class="comment"> * Created:   2011-11-28</span>
<a name="l00011"></a>00011 <span class="comment"> * Copyright: sleepiforest (http://weibo.com/sleepiforest)</span>
<a name="l00012"></a>00012 <span class="comment"> * License:</span>
<a name="l00013"></a>00013 <span class="comment"> **************************************************************/</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;<a class="code" href="_client_main_8h.html">ClientMain.h</a>&quot;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;wx/msgdlg.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;wx/xml/xml.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;wx/sstream.h&gt;</span>
<a name="l00019"></a>00019 <span class="comment">//(*InternalHeaders(ClientFrame)</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;wx/intl.h&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;wx/string.h&gt;</span>
<a name="l00022"></a>00022 <span class="comment">//*)</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="comment">//helper functions</span>
<a name="l00025"></a><a class="code" href="_client_main_8cpp.html#ad6438f1e9a52a97d8c47b461a64b837f">00025</a> <span class="keyword">enum</span> <a class="code" href="_client_main_8cpp.html#ad6438f1e9a52a97d8c47b461a64b837f">wxbuildinfoformat</a> {
<a name="l00026"></a><a class="code" href="_client_main_8cpp.html#ad6438f1e9a52a97d8c47b461a64b837faf34cf4880b9e5e417182a04ea274043c">00026</a>     <a class="code" href="_client_main_8cpp.html#ad6438f1e9a52a97d8c47b461a64b837faf34cf4880b9e5e417182a04ea274043c">short_f</a>, <a class="code" href="_client_main_8cpp.html#ad6438f1e9a52a97d8c47b461a64b837fa7ed9aefb554be1a3e8b51f0d58c60c18">long_f</a> };
<a name="l00027"></a>00027 
<a name="l00028"></a><a class="code" href="_client_main_8cpp.html#afdd094b13f51c9d282a71d71dd0595ab">00028</a> wxString <a class="code" href="_client_main_8cpp.html#afdd094b13f51c9d282a71d71dd0595ab">wxbuildinfo</a>(<a class="code" href="_client_main_8cpp.html#ad6438f1e9a52a97d8c47b461a64b837f">wxbuildinfoformat</a> format)
<a name="l00029"></a>00029 {
<a name="l00030"></a>00030     wxString wxbuild(wxVERSION_STRING);
<a name="l00031"></a>00031 
<a name="l00032"></a>00032     <span class="keywordflow">if</span> (format == <a class="code" href="_client_main_8cpp.html#ad6438f1e9a52a97d8c47b461a64b837fa7ed9aefb554be1a3e8b51f0d58c60c18">long_f</a> )
<a name="l00033"></a>00033     {
<a name="l00034"></a>00034 <span class="preprocessor">#if defined(__WXMSW__)</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>        wxbuild &lt;&lt; _T(<span class="stringliteral">&quot;-Windows&quot;</span>);
<a name="l00036"></a>00036 <span class="preprocessor">#elif defined(__UNIX__)</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>        wxbuild &lt;&lt; _T(<span class="stringliteral">&quot;-Linux&quot;</span>);
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="preprocessor">#if wxUSE_UNICODE</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span>        wxbuild &lt;&lt; _T(<span class="stringliteral">&quot;-Unicode build&quot;</span>);
<a name="l00042"></a>00042 <span class="preprocessor">#else</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span>        wxbuild &lt;&lt; _T(<span class="stringliteral">&quot;-ANSI build&quot;</span>);
<a name="l00044"></a>00044 <span class="preprocessor">#endif // wxUSE_UNICODE</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span>    }
<a name="l00046"></a>00046 
<a name="l00047"></a>00047     <span class="keywordflow">return</span> wxbuild;
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#a2362a0fedb48497f056610d232d245b3">ClientFrame::SOCKET_ID</a> = wxNewId();
<a name="l00050"></a>00050 <span class="comment">//(*IdInit(ClientFrame)</span>
<a name="l00051"></a>00051 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#acebe7921e9b05c387002d959d66d611f">ClientFrame::ID_PANEL3</a> = wxNewId();
<a name="l00052"></a>00052 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#adb5644b1b7f98120094189f783dfb819">ClientFrame::ID_TEXTCTRL1</a> = wxNewId();
<a name="l00053"></a>00053 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#afe54a6d2afe793a099740eb5174e4c7d">ClientFrame::ID_PANEL2</a> = wxNewId();
<a name="l00054"></a>00054 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#ad55cf2202f66b48138ceeb2fefc1ffa5">ClientFrame::ID_TEXTCTRL2</a> = wxNewId();
<a name="l00055"></a>00055 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#ae990ba416a184c4f4114db0ca6ad32b2">ClientFrame::ID_PANEL1</a> = wxNewId();
<a name="l00056"></a>00056 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#a5551cbc3667271a9117d2ebce5ed4abd">ClientFrame::idMenuQuit</a> = wxNewId();
<a name="l00057"></a>00057 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#af1a7efc4a544f2e40572b25783106c49">ClientFrame::idMenuAbout</a> = wxNewId();
<a name="l00058"></a>00058 <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="class_client_frame.html#ab462d441645b55c38f049d9227cb200d">ClientFrame::ID_STATUSBAR1</a> = wxNewId();
<a name="l00059"></a>00059 <span class="comment">//*)</span>
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 BEGIN_EVENT_TABLE(<a class="code" href="class_client_frame.html">ClientFrame</a>,wxFrame)
<a name="l00062"></a>00062         EVT_SOCKET(SOCKET_ID,  <a class="code" href="class_client_frame.html">ClientFrame</a>::OnSocketEvent)
<a name="l00063"></a>00063     <span class="comment">//(*EventTable(ClientFrame)</span>
<a name="l00064"></a>00064     <span class="comment">//*)</span>
<a name="l00065"></a>00065 END_EVENT_TABLE()
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="class_client_frame.html#a168b53f469815f6e4a653ee767b84e37">00067</a> <a class="code" href="class_client_frame.html">ClientFrame</a>::<a class="code" href="class_client_frame.html">ClientFrame</a>(wxWindow* parent):
<a name="l00068"></a>00068     connectDlg(0),queryDlg(0)
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070     <span class="comment">//(*Initialize(ClientFrame)</span>
<a name="l00071"></a>00071     wxMenuItem* MenuItem2;
<a name="l00072"></a>00072     wxMenuItem* MenuItem1;
<a name="l00073"></a>00073     wxBoxSizer* BoxSizer2;
<a name="l00074"></a>00074     wxMenu* Menu1;
<a name="l00075"></a>00075     wxBoxSizer* BoxSizer1;
<a name="l00076"></a>00076     wxMenuBar* MenuBar1;
<a name="l00077"></a>00077     wxMenu* Menu2;
<a name="l00078"></a>00078 
<a name="l00079"></a>00079     Create(parent, wxID_ANY, _(<span class="stringliteral">&quot;手机导购测试用~~&quot;</span>), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T(<span class="stringliteral">&quot;wxID_ANY&quot;</span>));
<a name="l00080"></a>00080     BoxSizer1 = <span class="keyword">new</span> wxBoxSizer(wxHORIZONTAL);
<a name="l00081"></a>00081     BoxSizer2 = <span class="keyword">new</span> wxBoxSizer(wxVERTICAL);
<a name="l00082"></a>00082     Panel3 = <span class="keyword">new</span> wxPanel(<span class="keyword">this</span>, ID_PANEL3, wxDefaultPosition, wxSize(487,24), wxTAB_TRAVERSAL, _T(<span class="stringliteral">&quot;ID_PANEL3&quot;</span>));
<a name="l00083"></a>00083     BoxSizer2-&gt;Add(Panel3, 0, wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
<a name="l00084"></a>00084     txLog = <span class="keyword">new</span> <a class="code" href="class_text_log.html" title="显示聊天对白的文本框">TextLog</a>(<span class="keyword">this</span>, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxSize(487,231), wxTE_AUTO_SCROLL|wxTE_MULTILINE|wxTE_READONLY|wxTE_LEFT, wxDefaultValidator, _T(<span class="stringliteral">&quot;ID_TEXTCTRL1&quot;</span>));
<a name="l00085"></a>00085     BoxSizer2-&gt;Add(txLog, 1, wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
<a name="l00086"></a>00086     Panel2 = <span class="keyword">new</span> wxPanel(<span class="keyword">this</span>, ID_PANEL2, wxDefaultPosition, wxSize(121,26), wxTAB_TRAVERSAL, _T(<span class="stringliteral">&quot;ID_PANEL2&quot;</span>));
<a name="l00087"></a>00087     BoxSizer2-&gt;Add(Panel2, 0, wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
<a name="l00088"></a>00088     txEdit = <span class="keyword">new</span> wxTextCtrl(<span class="keyword">this</span>, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(487,70), wxTE_PROCESS_ENTER, wxDefaultValidator, _T(<span class="stringliteral">&quot;ID_TEXTCTRL2&quot;</span>));
<a name="l00089"></a>00089     txEdit-&gt;SetFocus();
<a name="l00090"></a>00090     BoxSizer2-&gt;Add(txEdit, 0, wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
<a name="l00091"></a>00091     Panel1 = <span class="keyword">new</span> wxPanel(<span class="keyword">this</span>, ID_PANEL1, wxDefaultPosition, wxSize(487,25), wxTAB_TRAVERSAL, _T(<span class="stringliteral">&quot;ID_PANEL1&quot;</span>));
<a name="l00092"></a>00092     BoxSizer2-&gt;Add(Panel1, 0, wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
<a name="l00093"></a>00093     BoxSizer1-&gt;Add(BoxSizer2, 1, wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
<a name="l00094"></a>00094     SetSizer(BoxSizer1);
<a name="l00095"></a>00095     MenuBar1 = <span class="keyword">new</span> wxMenuBar();
<a name="l00096"></a>00096     Menu1 = <span class="keyword">new</span> wxMenu();
<a name="l00097"></a>00097     MenuItem1 = <span class="keyword">new</span> wxMenuItem(Menu1, idMenuQuit, _(<span class="stringliteral">&quot;Quit\tAlt-F4&quot;</span>), _(<span class="stringliteral">&quot;Quit the application&quot;</span>), wxITEM_NORMAL);
<a name="l00098"></a>00098     Menu1-&gt;Append(MenuItem1);
<a name="l00099"></a>00099     MenuBar1-&gt;Append(Menu1, _(<span class="stringliteral">&quot;&amp;File&quot;</span>));
<a name="l00100"></a>00100     Menu2 = <span class="keyword">new</span> wxMenu();
<a name="l00101"></a>00101     MenuItem2 = <span class="keyword">new</span> wxMenuItem(Menu2, idMenuAbout, _(<span class="stringliteral">&quot;About\tF1&quot;</span>), _(<span class="stringliteral">&quot;Show info about this application&quot;</span>), wxITEM_NORMAL);
<a name="l00102"></a>00102     Menu2-&gt;Append(MenuItem2);
<a name="l00103"></a>00103     MenuBar1-&gt;Append(Menu2, _(<span class="stringliteral">&quot;Help&quot;</span>));
<a name="l00104"></a>00104     SetMenuBar(MenuBar1);
<a name="l00105"></a>00105     StatusBar1 = <span class="keyword">new</span> wxStatusBar(<span class="keyword">this</span>, ID_STATUSBAR1, 0, _T(<span class="stringliteral">&quot;ID_STATUSBAR1&quot;</span>));
<a name="l00106"></a>00106     <span class="keywordtype">int</span> __wxStatusBarWidths_1[1] = { -1 };
<a name="l00107"></a>00107     <span class="keywordtype">int</span> __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
<a name="l00108"></a>00108     StatusBar1-&gt;SetFieldsCount(1,__wxStatusBarWidths_1);
<a name="l00109"></a>00109     StatusBar1-&gt;SetStatusStyles(1,__wxStatusBarStyles_1);
<a name="l00110"></a>00110     SetStatusBar(StatusBar1);
<a name="l00111"></a>00111     BoxSizer1-&gt;Fit(<span class="keyword">this</span>);
<a name="l00112"></a>00112     BoxSizer1-&gt;SetSizeHints(<span class="keyword">this</span>);
<a name="l00113"></a>00113 
<a name="l00114"></a>00114     Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_ENTER,(wxObjectEventFunction)&amp;<a class="code" href="class_client_frame.html#a2d6eb0b6ff71d5d06d6064d498646636">ClientFrame::OntxEditText</a>);
<a name="l00115"></a>00115     Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&amp;<a class="code" href="class_client_frame.html#ad5585141cf48f0f17abdd337add3564e">ClientFrame::OnQuit</a>);
<a name="l00116"></a>00116     Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&amp;<a class="code" href="class_client_frame.html#aaee6a026a7b3f3f942b733f0a738090e">ClientFrame::OnAbout</a>);
<a name="l00117"></a>00117     <span class="comment">//*)</span>
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119 
<a name="l00120"></a><a class="code" href="class_client_frame.html#a74ce0b58508f68e4eeabc083ff57b3ba">00120</a> <a class="code" href="class_client_frame.html#a74ce0b58508f68e4eeabc083ff57b3ba">ClientFrame::~ClientFrame</a>()
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122         <span class="keywordflow">if</span>(<a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>) <a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>-&gt;Destroy();
<a name="l00123"></a>00123         <span class="comment">//wxMessageBox(_(&quot;delete!&quot;));</span>
<a name="l00124"></a>00124     <span class="comment">//(*Destroy(ClientFrame)</span>
<a name="l00125"></a>00125     <span class="comment">//*)</span>
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127 
<a name="l00128"></a><a class="code" href="class_client_frame.html#ae39beabd4dd0309c7b519f5269d18c2e">00128</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#ae39beabd4dd0309c7b519f5269d18c2e">ClientFrame::Show</a>()
<a name="l00129"></a>00129 {
<a name="l00130"></a>00130     <span class="keywordflow">if</span>((<a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>=<a class="code" href="class_client_frame.html#a88f567ea6ada7e5c88da0b2ddaa9b3a4">connectDlg</a>.<a class="code" href="class_connection_dlg.html#af2352027e0c26e29122285f6474c1197">GetConnection</a>(<span class="keyword">this</span>))!=NULL)
<a name="l00131"></a>00131     {
<a name="l00132"></a>00132         <a class="code" href="class_client_frame.html#a992ddfe167c0db1bd16f67f715332888">serverName</a> = <a class="code" href="class_client_frame.html#a88f567ea6ada7e5c88da0b2ddaa9b3a4">connectDlg</a>.<a class="code" href="class_connection_dlg.html#ab831c3b1cf25e61f00f1a0fdad4b4b47">GetServerName</a>();
<a name="l00133"></a>00133         <a class="code" href="class_client_frame.html#ad6d934ab7eb18977ad24a2b12eb5db09">name</a> = <a class="code" href="class_client_frame.html#a88f567ea6ada7e5c88da0b2ddaa9b3a4">connectDlg</a>.<a class="code" href="class_connection_dlg.html#adfe05cd2c81b9b0736872f96fd5bca4c">GetUserName</a>();
<a name="l00134"></a>00134         <a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>-&gt;SetEventHandler(*<span class="keyword">this</span>,<a class="code" href="class_client_frame.html#a2362a0fedb48497f056610d232d245b3">SOCKET_ID</a>);
<a name="l00135"></a>00135         <a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>-&gt;SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
<a name="l00136"></a>00136         <a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>-&gt;Notify(<span class="keyword">true</span>);
<a name="l00137"></a>00137         <span class="keywordflow">if</span>(<a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>-&gt;WaitForRead(0)) <a class="code" href="class_client_frame.html#a62f7c461f3a4da6d7be83c21cab54730">OnRead</a>();
<a name="l00138"></a>00138         <a class="code" href="class_client_frame.html#a93b186d5ba94f84201708c4958c47d2a">txEdit</a>-&gt;SetFocus();
<a name="l00139"></a>00139         <a class="code" href="class_client_frame.html#ae39beabd4dd0309c7b519f5269d18c2e">wxFrame::Show</a>();
<a name="l00140"></a>00140     }
<a name="l00141"></a>00141     <span class="keywordflow">else</span>
<a name="l00142"></a>00142     {
<a name="l00143"></a>00143         Destroy();
<a name="l00144"></a>00144     }
<a name="l00145"></a>00145 }
<a name="l00146"></a>00146 
<a name="l00147"></a>00147 
<a name="l00148"></a><a class="code" href="class_client_frame.html#ad5585141cf48f0f17abdd337add3564e">00148</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#ad5585141cf48f0f17abdd337add3564e">ClientFrame::OnQuit</a>(wxCommandEvent&amp; event)
<a name="l00149"></a>00149 {
<a name="l00150"></a>00150     Close();
<a name="l00151"></a>00151 }
<a name="l00152"></a>00152 
<a name="l00153"></a><a class="code" href="class_client_frame.html#aaee6a026a7b3f3f942b733f0a738090e">00153</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#aaee6a026a7b3f3f942b733f0a738090e">ClientFrame::OnAbout</a>(wxCommandEvent&amp; event)
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155     wxString msg = <a class="code" href="_client_main_8cpp.html#afdd094b13f51c9d282a71d71dd0595ab">wxbuildinfo</a>(<a class="code" href="_client_main_8cpp.html#ad6438f1e9a52a97d8c47b461a64b837fa7ed9aefb554be1a3e8b51f0d58c60c18">long_f</a>);
<a name="l00156"></a>00156     wxMessageBox(msg, _(<span class="stringliteral">&quot;Welcome to...&quot;</span>));
<a name="l00157"></a>00157 }
<a name="l00158"></a><a class="code" href="class_client_frame.html#a165275bb47654058c5ec28375a94f3bf">00158</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#a165275bb47654058c5ec28375a94f3bf">ClientFrame::SendMsg</a>(wxString msg)
<a name="l00159"></a>00159 {
<a name="l00160"></a>00160     <span class="keywordtype">char</span> buff[1010];
<a name="l00161"></a>00161     <span class="keywordtype">int</span> len = wxConvLibc.FromWChar(buff,1000,msg);
<a name="l00162"></a>00162     <span class="keywordflow">if</span>(<a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>-&gt;WriteMsg(buff,len).Error())
<a name="l00163"></a>00163     {
<a name="l00164"></a>00164         wxMessageBox(_(<span class="stringliteral">&quot;连接超时!! 退出程序!!&quot;</span>));
<a name="l00165"></a>00165                 Close();
<a name="l00166"></a>00166     }
<a name="l00167"></a>00167 }
<a name="l00168"></a>00168 
<a name="l00169"></a><a class="code" href="class_client_frame.html#a2d6eb0b6ff71d5d06d6064d498646636">00169</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#a2d6eb0b6ff71d5d06d6064d498646636">ClientFrame::OntxEditText</a>(wxCommandEvent&amp; event)
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171         wxString msg = <a class="code" href="class_client_frame.html#a93b186d5ba94f84201708c4958c47d2a">txEdit</a>-&gt;GetValue();
<a name="l00172"></a>00172         <a class="code" href="class_client_frame.html#a165275bb47654058c5ec28375a94f3bf">SendMsg</a>(msg);
<a name="l00173"></a>00173         <a class="code" href="class_client_frame.html#a654403e0bfd0aef75941a9162eb42003">txLog</a>-&gt;<a class="code" href="class_text_log.html#aef33ef35e4d7dbf90d859c5ef5c529a4" title="添加聊天记录">AddLog</a>(<a class="code" href="class_client_frame.html#ad6d934ab7eb18977ad24a2b12eb5db09">name</a>,msg);
<a name="l00174"></a>00174         <a class="code" href="class_client_frame.html#a93b186d5ba94f84201708c4958c47d2a">txEdit</a>-&gt;Clear();
<a name="l00175"></a>00175 }
<a name="l00176"></a><a class="code" href="class_client_frame.html#a24e870523866761377b653818a65680e">00176</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#a24e870523866761377b653818a65680e">ClientFrame::OnSocketEvent</a>(wxSocketEvent&amp; event)
<a name="l00177"></a>00177 {
<a name="l00178"></a>00178         <span class="comment">//wxMessageBox(_(&quot;消息&quot;));</span>
<a name="l00179"></a>00179         <span class="keywordflow">switch</span>(event.GetSocketEvent())
<a name="l00180"></a>00180         {
<a name="l00181"></a>00181                 <span class="keywordflow">case</span> wxSOCKET_INPUT: <a class="code" href="class_client_frame.html#a62f7c461f3a4da6d7be83c21cab54730">OnRead</a>();<span class="keywordflow">break</span>;
<a name="l00182"></a>00182                 <span class="keywordflow">case</span> wxSOCKET_LOST: <a class="code" href="class_client_frame.html#a757a532858d222e9eb2e04c2034ca047">OnLost</a>();<span class="keywordflow">break</span>;
<a name="l00183"></a>00183                 <span class="keywordflow">default</span>: wxMessageBox(_(<span class="stringliteral">&quot;未知消息类型&quot;</span>));
<a name="l00184"></a>00184         }
<a name="l00185"></a>00185 }
<a name="l00186"></a><a class="code" href="class_client_frame.html#a62f7c461f3a4da6d7be83c21cab54730">00186</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#a62f7c461f3a4da6d7be83c21cab54730">ClientFrame::OnRead</a>()
<a name="l00187"></a>00187 {
<a name="l00188"></a>00188         <span class="keywordtype">char</span> buff[1010];
<a name="l00189"></a>00189         <span class="keywordtype">int</span> len = <a class="code" href="class_client_frame.html#a60f28a5555d341b0f0eb2f0ba6b6f2a0">sock</a>-&gt;ReadMsg(buff,1000).LastCount();
<a name="l00190"></a>00190         buff[len] = 0;
<a name="l00191"></a>00191         <span class="comment">//wxMessageBox(_(&quot;Receive String: &quot;)+wxString(buff,wxConvLibc));</span>
<a name="l00192"></a>00192     wxStringInputStream rev(wxString(buff,wxConvLibc));
<a name="l00193"></a>00193         wxXmlDocument doc(rev);
<a name="l00194"></a>00194         <span class="keywordflow">if</span>(!doc.IsOk()) <span class="keywordflow">return</span>;
<a name="l00195"></a>00195         wxXmlNode *node = doc.GetRoot();
<a name="l00196"></a>00196         <span class="comment">//wxMessageBox(_(&quot;Receive: &quot;)+node-&gt;GetName());</span>
<a name="l00197"></a>00197         <span class="keywordflow">while</span>(node)
<a name="l00198"></a>00198     {
<a name="l00199"></a>00199         <span class="keywordflow">if</span>(node-&gt;GetName()==_(<span class="stringliteral">&quot;Setting&quot;</span>))
<a name="l00200"></a>00200         {
<a name="l00201"></a>00201             <a class="code" href="class_client_frame.html#a6584f5d71232ac25d30b9f6605672ca7">OnSetting</a>(node-&gt;GetChildren());
<a name="l00202"></a>00202         }
<a name="l00203"></a>00203         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(node-&gt;GetName()==_(<span class="stringliteral">&quot;Respond&quot;</span>))
<a name="l00204"></a>00204         {
<a name="l00205"></a>00205             <a class="code" href="class_client_frame.html#a15d6c241ccf7fa8157163cb9a9e109e9">OnSendRespond</a>(node-&gt;GetChildren());
<a name="l00206"></a>00206         }
<a name="l00207"></a>00207         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(node-&gt;GetName()==_(<span class="stringliteral">&quot;Message&quot;</span>))
<a name="l00208"></a>00208         {
<a name="l00209"></a>00209             <a class="code" href="class_client_frame.html#a81453de53c35bfb78e52bef78825c941">OnMessage</a>(node-&gt;GetChildren());
<a name="l00210"></a>00210             <span class="comment">//txLog-&gt;AddLog(serverName,);</span>
<a name="l00211"></a>00211         }
<a name="l00212"></a>00212         node = node-&gt;GetNext();
<a name="l00213"></a>00213     }
<a name="l00214"></a>00214 }
<a name="l00215"></a><a class="code" href="class_client_frame.html#a15d6c241ccf7fa8157163cb9a9e109e9">00215</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#a15d6c241ccf7fa8157163cb9a9e109e9">ClientFrame::OnSendRespond</a>(wxXmlNode *node)
<a name="l00216"></a>00216 {
<a name="l00217"></a>00217     wxString query;
<a name="l00218"></a>00218     <span class="keywordflow">while</span>(node)
<a name="l00219"></a>00219     {
<a name="l00220"></a>00220         <span class="keywordflow">if</span>(node-&gt;GetName()==_(<span class="stringliteral">&quot;Query&quot;</span>))
<a name="l00221"></a>00221         {
<a name="l00222"></a>00222             query = node-&gt;GetContent();
<a name="l00223"></a>00223         }
<a name="l00224"></a>00224         node = node-&gt;GetNext();
<a name="l00225"></a>00225     }
<a name="l00226"></a>00226     wxString type = <a class="code" href="class_client_frame.html#a375144381a28a6517559df34ab4fcdf6">queryDlg</a>.<a class="code" href="class_add_query_dlg.html#a1c89e69aaef6c5ca7265d562dc87b2cc">ChooseQueryType</a>(<span class="keyword">this</span>,query);
<a name="l00227"></a>00227     <a class="code" href="class_client_frame.html#a93b186d5ba94f84201708c4958c47d2a">txEdit</a>-&gt;SetFocus();
<a name="l00228"></a>00228     wxString msg=_(<span class="stringliteral">&quot;&lt;Respond&gt;\n&quot;</span>);
<a name="l00229"></a>00229     wxString that = _(<span class="stringliteral">&quot;&quot;</span>);
<a name="l00230"></a>00230     <span class="keywordflow">if</span>(!type.IsEmpty())
<a name="l00231"></a>00231     {
<a name="l00232"></a>00232         msg += _(<span class="stringliteral">&quot;&lt;QueryType&gt;&quot;</span>)+type+_(<span class="stringliteral">&quot;&lt;/QueryType&gt;\n&quot;</span>);
<a name="l00233"></a>00233         <span class="keywordflow">if</span>(<a class="code" href="class_client_frame.html#a375144381a28a6517559df34ab4fcdf6">queryDlg</a>.<a class="code" href="class_add_query_dlg.html#a4352f7e9eaf6618f28d2367c93185586">IsThat</a>()) msg += _(<span class="stringliteral">&quot;&lt;That&gt;&quot;</span>)+<a class="code" href="class_client_frame.html#a654403e0bfd0aef75941a9162eb42003">txLog</a>-&gt;<a class="code" href="class_text_log.html#a78055a86dae63b076fc7372a1a5c7b08" title="获取name说的最后一句话">LastMsg</a>(<a class="code" href="class_client_frame.html#a992ddfe167c0db1bd16f67f715332888">serverName</a>)+_(<span class="stringliteral">&quot;&lt;/That&gt;\n&quot;</span>);
<a name="l00234"></a>00234     }
<a name="l00235"></a>00235     msg += _(<span class="stringliteral">&quot;&lt;/Respond&gt;&quot;</span>);
<a name="l00236"></a>00236     <span class="comment">//wxMessageBox(msg);</span>
<a name="l00237"></a>00237     <a class="code" href="class_client_frame.html#a165275bb47654058c5ec28375a94f3bf">SendMsg</a>(msg);
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239 
<a name="l00240"></a><a class="code" href="class_client_frame.html#a6584f5d71232ac25d30b9f6605672ca7">00240</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#a6584f5d71232ac25d30b9f6605672ca7">ClientFrame::OnSetting</a>(wxXmlNode *node)
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242     <span class="comment">//wxMessageBox(_(&quot;setting&quot;));</span>
<a name="l00243"></a>00243     <span class="keywordflow">while</span>(node)
<a name="l00244"></a>00244     {
<a name="l00245"></a>00245         <span class="keywordflow">if</span>(node-&gt;GetName()==_(<span class="stringliteral">&quot;AddQueryType&quot;</span>))
<a name="l00246"></a>00246         {
<a name="l00247"></a>00247             <a class="code" href="class_client_frame.html#a375144381a28a6517559df34ab4fcdf6">queryDlg</a>.<a class="code" href="class_add_query_dlg.html#a15669968c49c0d26cc2ef7e9d9df4be2">AddQueryType</a>(node-&gt;GetChildren()-&gt;GetContent());
<a name="l00248"></a>00248         }
<a name="l00249"></a>00249         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(node-&gt;GetName()==_(<span class="stringliteral">&quot;RemoveQueryType&quot;</span>))
<a name="l00250"></a>00250         {
<a name="l00251"></a>00251             <a class="code" href="class_client_frame.html#a375144381a28a6517559df34ab4fcdf6">queryDlg</a>.<a class="code" href="class_add_query_dlg.html#a2197d96e55996dd6e3e634f61677cce4">RemoveQueryType</a>(node-&gt;GetChildren()-&gt;GetContent());
<a name="l00252"></a>00252         }
<a name="l00253"></a>00253         node = node-&gt;GetNext();
<a name="l00254"></a>00254     }
<a name="l00255"></a>00255     <a class="code" href="class_client_frame.html#a165275bb47654058c5ec28375a94f3bf">SendMsg</a>(_(<span class="stringliteral">&quot;&lt;Ack&gt;Setting&lt;/Ack&gt;&quot;</span>));
<a name="l00256"></a>00256 }
<a name="l00257"></a><a class="code" href="class_client_frame.html#a81453de53c35bfb78e52bef78825c941">00257</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#a81453de53c35bfb78e52bef78825c941">ClientFrame::OnMessage</a>(wxXmlNode* node)
<a name="l00258"></a>00258 {
<a name="l00259"></a>00259     wxString content;
<a name="l00260"></a>00260     <span class="keywordflow">while</span>(node)
<a name="l00261"></a>00261     {
<a name="l00262"></a>00262         <span class="keywordflow">if</span>(node-&gt;GetName()==_(<span class="stringliteral">&quot;Content&quot;</span>))
<a name="l00263"></a>00263         {
<a name="l00264"></a>00264             <a class="code" href="class_client_frame.html#a654403e0bfd0aef75941a9162eb42003">txLog</a>-&gt;<a class="code" href="class_text_log.html#aef33ef35e4d7dbf90d859c5ef5c529a4" title="添加聊天记录">AddLog</a>(<a class="code" href="class_client_frame.html#a992ddfe167c0db1bd16f67f715332888">serverName</a>,node-&gt;GetChildren()-&gt;GetContent());
<a name="l00265"></a>00265         }
<a name="l00266"></a>00266         node = node-&gt;GetNext();
<a name="l00267"></a>00267     }
<a name="l00268"></a>00268 }
<a name="l00269"></a>00269 
<a name="l00270"></a><a class="code" href="class_client_frame.html#a757a532858d222e9eb2e04c2034ca047">00270</a> <span class="keywordtype">void</span> <a class="code" href="class_client_frame.html#a757a532858d222e9eb2e04c2034ca047">ClientFrame::OnLost</a>()
<a name="l00271"></a>00271 {
<a name="l00272"></a>00272         wxMessageBox(_(<span class="stringliteral">&quot;连接中断!! 退出程序!!&quot;</span>));
<a name="l00273"></a>00273         Close();
<a name="l00274"></a>00274 }
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>全部</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>类</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>命名空间</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>文件</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>函数</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>变量</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>枚举</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>枚举值</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>宏定义</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_client_main_8cpp.html">ClientMain.cpp</a>      </li>

    <li class="footer">Generated at 2012年一月9日 星期一 09:15:28 for RobotClient by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
